<template>
  <el-container class="lp-Home">
    <!-- 侧边栏 -->
    <el-aside width="200"
      ><div class="aside-logo"></div>

      <submenu></submenu>
    </el-aside>
    <el-container>
      <!-- 头部 -->
      <el-header>
        <el-row type="flex" class="row-bg" justify="space-between">
          <el-col :span="6">
            <div>
              <i class="iconfont menu" :class="menuColl" @click="collapse"></i>
            </div>
          </el-col>
          <el-col :span="6">
            <h3 style="color: #fff">路平管理系统</h3>
          </el-col>
          <el-col :span="6">
            <div class="el-col-right">
              <div class="portrait">
                <el-avatar :size="50" :src="circleUrl"></el-avatar>
              </div>
              <span class="wecom">{{ userInfo.nickname }} </span>
              <a href="javascript:;" @click="quit">退出</a>
            </div>
          </el-col>
        </el-row>
      </el-header>
      <!-- 主体 -->
      <el-main>
        <el-breadcrumb separator=">">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item v-for="item in crubms" :key="item.name" :to="{ name: item.name }">{{item.meta.name}}</el-breadcrumb-item>
          
        </el-breadcrumb>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { mapState, mapMutations } from "vuex";
import * as ax from "../api";
import Submenu from "../components/Submenu.vue";

export default {
  components: { Submenu },
  mounted() {
    ax.loginlogApi().then((res) => {});
  },
  computed: {
    ...mapState(["userInfo", "menuFlag","crubms"]),
    circleUrl() {
      return this.userInfo.headimgurl
        ? this.userInfo.headimgurl
        : "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png";
    },

    menuColl() {
      return this.menuFlag ? "el-icon-s-unfold" : "el-icon-s-fold";
    },
  },
  data() {
    return {};
  },
  methods: {
    /* 惨淡蓝缩进 */
    ...mapMutations(["SET_MENUFLAG"]),
    collapse() {
      this.SET_MENUFLAG();
    },

    quit() {
      this.$router.push("./login");
      localStorage.removeItem("lp-token");
      //因为addroutes不能删除所以要刷新页面
      window.location.reload();
    },
  },
};
</script>
<style lang="less" scoped>
/* heard样式 */
.aside-logo {
  width: 100%;
  height: 60px;
  background-image: url("../assets/imgs/logo.be8bbddf.png");
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: 50%;
}
.wecom {
  margin: 0 10px;
  color: #fff;
}
.el-col-right {
  height: 100%;
  display: flex;
  justify-content: flex-end;
  float: none !important;
  margin-right: 20px;
}
.portrait {
  height: 100%;
  margin-top: 5px;
}
.el-col-6 {
  text-align: left;

  height: 60px;
}
.menu {
  font-size: 40px !important;
  margin-top: 9px !important;
  color: #fff !important;
  cursor: pointer;
}

.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.row-bg {
  background-color: #CC3399;
}

/* 布局样式 */

.lp-Home {
  height: 100% !important;
}
.el-header,
.el-footer {
  background-color: #CC3399;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #ff99ff;
  color: #333;
  text-align: center;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>